package reflect;

import java.lang.reflect.Method;

public class Test2 {
    public static void main(String[] args) throws Exception{
        Class cls = Class.forName("reflect.Person");
        Object o = cls.newInstance();
        Method[] methods = cls.getMethods();

        for (Method method : methods) {
          if(method.getName().contains("say")&&method.getParameterCount()==0){
              System.out.println("自动调用的方法:"+method.getName());
              method.invoke(o);
          }

        }



    }
}
